package com.poetize.plus.config;

import com.poetize.plus.properties.ProjectProperties;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zuosy
 * @created 2024/3/29 9:36
 */
@Configuration
@RequiredArgsConstructor
public class SwaggerConfig {

    private final ProjectProperties projectProperties;

    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info().title(projectProperties.getName())
                        .description(projectProperties.getName() + "接口文档")
                        .contact(new Contact()
                                .name("zuosy")
                        )
                        .version(projectProperties.getVersion())
                        .license(new License()
                                .name("Apache 2.0")
                                .url("http://springdoc.org")
                        )
                )
                .externalDocs(new ExternalDocumentation()
                        .description("外部文档")
                        .url("https://springshop.wiki.github.org/docs"));
    }
}
